﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Web;
using DataAccessLayer;

namespace ServiceLayer.Entity
{
    [DataContract]
    public class AdjustmentDetailW
    {
        int adjDetailID;
        int adjVoucherID;
        string itemCode;
        int quantity;
        string reason;
        string supplierID;
        int stockHistoryID;

        [DataMember]
        public int AdjDetailID
        {
            get { return adjDetailID; }
            set { adjDetailID = value; }
        }

        [DataMember]
        public int AdjVoucherID
        {
            get { return adjVoucherID; }
            set { adjVoucherID = value; }
        }

        [DataMember]
        public string ItemCode
        {
            get { return itemCode; }
            set { itemCode = value; }
        }

        [DataMember]
        public int Quantity
        {
            get { return quantity; }
            set { quantity = value; }
        }

        [DataMember]
        public string Reason
        {
            get { return reason; }
            set { reason = value; }
        }

        [DataMember]
        public string SupplierID
        {
            get { return supplierID; }
            set { supplierID = value; }
        }

        [DataMember]
        public int StockHistoryID
        {
            get { return stockHistoryID; }
            set { stockHistoryID = value; }
        }

        public static AdjustmentDetailW convert(AdjustmentDetail adjustmentDetail)
        {
            AdjustmentDetailW u = new AdjustmentDetailW();

            u.AdjDetailID = adjustmentDetail.AdjDetailID;
            u.AdjVoucherID = adjustmentDetail.AdjVoucherID.GetValueOrDefault();
            u.ItemCode = adjustmentDetail.ItemCode;
            u.Quantity = adjustmentDetail.Quantity.GetValueOrDefault();
            u.Reason = adjustmentDetail.Reason;
            u.SupplierID = adjustmentDetail.SupplierID;
            u.StockHistoryID = adjustmentDetail.StockHistoryID.GetValueOrDefault();

            return u;
        }

        public static List<AdjustmentDetailW> convertList(List<AdjustmentDetail> list)
        {
            List<AdjustmentDetailW> listW = new List<AdjustmentDetailW>();

            foreach (AdjustmentDetail x in list)
            {
                listW.Add(convert(x));
            }
            return listW;
        }


    }
}